import * as mars3d from "mars3d";
import {DATA} from "./data1";

const Cesium = mars3d.Cesium;


// TODO:这两个data写的一坨，接口也是一坨，但暂时没时间改

interface AreaData {
    name: string;
    type: string;
    radius: number;
    longtitude: number;
    latitude: number;
    altitude: number;
}

let areasData : {[key: string]: AreaData} = {};
let treeStruct : {[key: string]: any} = {};
DATA.forEach(element => {
    try{  
        let area : AreaData = element as AreaData;
        // console.log("-----------test------------",allowArea);
        areasData[area.name] = area;

        // 检查键是否存在
        if (!treeStruct.hasOwnProperty(area.type)) {
            // 如果不存在，则创建一个空字典，并将当前变量添加到字典中
            treeStruct[area.type] = {};
            treeStruct[area.type][area.name] = [area];
        } else {
            // 如果存在，则将当前变量添加到已有字典中
            treeStruct[area.type][area.name] = [area];
        }
    }
    catch(e){
        console.error("Fail to transform Data which came from sqlite3 to my AreaData.");
    }
});

// console.log("-----------test------------");
// console.log("areasData", areasData);
// console.log("treeStruct", treeStruct);


export {
    areasData,treeStruct
}